//
//  PhotoesScrollView.m
//  Runone
//
//  Created by ekkaLyn on 2017/3/13.
//  Copyright © 2017年 runone. All rights reserved.
//

#import "PhotoesScrollView.h"
#import "SDAutoLayout.h"
#import "UIView+Addition.h"

@interface PhotoesScrollView ()<UIScrollViewDelegate>



@end

@implementation PhotoesScrollView

-(instancetype)initWithFrame:(CGRect)frame {
    self=[super initWithFrame:frame];
    if (self) {
        [self setBackgroundColor:[UIColor colorWithRed:226.0 / 255 green:230.0 / 255 blue:240.0 / 255 alpha:1]];
        
        [self configUI];
//        [self layoutUI];
    }
    return self;
}

- (void) configUI {
    _scrollV = [UIScrollView new];
    _scrollV.delegate = self;
    _scrollV.bounces  = NO;
    [self addSubview:_scrollV];
    _scrollV.showsVerticalScrollIndicator   = NO;
    _scrollV.showsHorizontalScrollIndicator = YES;
    _scrollV.sd_layout.spaceToSuperView(UIEdgeInsetsZero);
}

- (void)setPhotoesArray:(NSArray *)photoesArray {
    CGFloat x = 0;
    CGRect frame = CGRectMake(0, 0, 100, 100);
    for (int i = 0 ; i < self.photoesArray.count; i++) {
        frame.origin.x = x;
        UIImageView *imageView = [[UIImageView alloc] initWithFrame:frame];
        [imageView setContentMode:UIViewContentModeScaleAspectFill];
        imageView.clipsToBounds = YES;
        imageView.image = self.photoesArray[i];
        imageView.tag = i;
        imageView.userInteractionEnabled = YES;
        [imageView addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(showBig:)]];
        x += frame.size.width + 5;
    }
    self.scrollV.contentSize = CGSizeMake(105 * self.photoesArray.count + 0.5, 0);
}

- (void) showBig:(UIImageView *)imageV{
    NSLog(@"点击放大");
}


@end
